package com.suse.service.admin.edu.controller;

import com.suse.common.config.response.R;
import com.suse.service.admin.edu.model.param.VideoSaveParam;
import com.suse.service.admin.edu.model.param.VideoUpdateParam;
import com.suse.service.admin.edu.service.VideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author 辜玉彬
 * @since 2022-08-11
 */
@Api(tags = "课时接口")
@RestController
@RequestMapping("/video")
public class VideoController {

    @Resource
    private VideoService videoService;

    @ApiOperation(value = "通过ID获取课时信息")
    @GetMapping("/info/{id}")
    public R getVideoInfoById(@PathVariable("id") String id) {
        return videoService.getVideoInfoById(id);
    }

    @ApiOperation(value = "添加课时")
    @PostMapping("/save")
    public R saveVideo(@Valid @RequestBody VideoSaveParam videoSaveParam) {
        return videoService.saveVideo(videoSaveParam);
    }

    @ApiOperation(value = "修改课时")
    @PutMapping("/update")
    public R updateVideo(@Valid @RequestBody VideoUpdateParam videoUpdateParam) {
        return videoService.updateVideo(videoUpdateParam);
    }

    @ApiOperation(value = "通过ID删除课时")
    @DeleteMapping("/remove/{id}")
    public R removeVideoById(@PathVariable("id") String id) {
        return videoService.removeVideoById(id);
    }

}

